package com.gxa.controller;

import com.gxa.common.base.RespResult;
import com.gxa.domain.entity.Storage;
import com.gxa.domain.entity.User;
import com.gxa.service.StorageService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * 万事顺意
 * Created with IntelliJ IDEA.
 * User: zwj
 * Date: 2024/07/1910:16
 * Description:
 */
@RestController
@RequestMapping("/storage")
public class StorageController {
    @Autowired
    private StorageService storageService;
    @GetMapping("/query")
    public RespResult query(Integer id){
        Storage byId= storageService.getById(id);
        return RespResult.success(byId);
    }
    @PostMapping("/save")
    public RespResult save(@RequestBody Storage storage){
        boolean save= storageService.save(storage);
        if (save){
            return RespResult.success(save);
        }
        return RespResult.error("添加失败");
    }
    @PostMapping("/update")
    public RespResult update(Storage storage){
        boolean b= storageService.updateById(storage);
        if (b){
            return RespResult.success(b);
        }
        return RespResult.error("修改失败");
    }
    @PostMapping("/delete")
    public RespResult delete(Integer id){
        boolean b= storageService.removeById(id);
        if (b){
            return RespResult.success(b);
        }
        return RespResult.error("删除失败");
    }
}
